package com.airforce.mappers;

import com.airforce.model.topic;
import org.apache.ibatis.jdbc.SQL;

public class topicSqlProvider {

    public String insertSelective(topic record) {
        SQL sql = new SQL();
        sql.INSERT_INTO("topic");
        
        if (record.getId() != null) {
            sql.VALUES("id", "#{id,jdbcType=INTEGER}");
        }
        
        if (record.getName() != null) {
            sql.VALUES("name", "#{name,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimea() != null) {
            sql.VALUES("optimeA", "#{optimea,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimeb() != null) {
            sql.VALUES("optimeB", "#{optimeb,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimec() != null) {
            sql.VALUES("optimeC", "#{optimec,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimed() != null) {
            sql.VALUES("optimeD", "#{optimed,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.VALUES("createtime", "#{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.VALUES("updatetime", "#{updatetime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getIdx() != null) {
            sql.VALUES("idx", "#{idx,jdbcType=INTEGER}");
        }
        
        return sql.toString();
    }

    public String updateByPrimaryKeySelective(topic record) {
        SQL sql = new SQL();
        sql.UPDATE("topic");
        
        if (record.getName() != null) {
            sql.SET("name = #{name,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimea() != null) {
            sql.SET("optimeA = #{optimea,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimeb() != null) {
            sql.SET("optimeB = #{optimeb,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimec() != null) {
            sql.SET("optimeC = #{optimec,jdbcType=VARCHAR}");
        }
        
        if (record.getOptimed() != null) {
            sql.SET("optimeD = #{optimed,jdbcType=VARCHAR}");
        }
        
        if (record.getCreatetime() != null) {
            sql.SET("createtime = #{createtime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getUpdatetime() != null) {
            sql.SET("updatetime = #{updatetime,jdbcType=TIMESTAMP}");
        }
        
        if (record.getIdx() != null) {
            sql.SET("idx = #{idx,jdbcType=INTEGER}");
        }
        
        sql.WHERE("id = #{id,jdbcType=INTEGER}");
        
        return sql.toString();
    }
}